<?php

/**
 * Invoice form base class.
 *
 * @method Invoice getObject() Returns the current form's model object
 *
 * @package    dashboard
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseInvoiceForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'invoice_id'           => new sfWidgetFormInputHidden(),
      'invoice_group'        => new sfWidgetFormInputText(),
      'invoice_groupdate'    => new sfWidgetFormDateTime(),
      'invoice_datestart'    => new sfWidgetFormDate(),
      'invoice_dateend'      => new sfWidgetFormDate(),
      'invoice_servicestart' => new sfWidgetFormDate(),
      'invoice_serviceend'   => new sfWidgetFormDate(),
      'invoice_benchmark'    => new sfWidgetFormInputText(),
      'invoice_newprice'     => new sfWidgetFormInputText(),
      'invoice_hauler_cost'  => new sfWidgetFormInputText(),
      'invoice_comments'     => new sfWidgetFormTextarea(),
      'invoice_deleted'      => new sfWidgetFormChoice(array('choices' => array('no' => 'no', 'yes' => 'yes'))),
      'invoice_paid'         => new sfWidgetFormChoice(array('choices' => array('no' => 'no', 'yes' => 'yes'))),
      'invoice_hauler_paid'  => new sfWidgetFormChoice(array('choices' => array('no' => 'no', 'yes' => 'yes'))),
      'invoice_sent'         => new sfWidgetFormChoice(array('choices' => array('yes' => 'yes', 'no' => 'no'))),
      'invoice_send_date'    => new sfWidgetFormDateTime(),
      'invoice_last_send'    => new sfWidgetFormDateTime(),
      'invoice_paid_date'    => new sfWidgetFormDateTime(),
      'account_id'           => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Account'), 'add_empty' => false)),
    ));

    $this->setValidators(array(
      'invoice_id'           => new sfValidatorChoice(array('choices' => array($this->getObject()->get('invoice_id')), 'empty_value' => $this->getObject()->get('invoice_id'), 'required' => false)),
      'invoice_group'        => new sfValidatorInteger(),
      'invoice_groupdate'    => new sfValidatorDateTime(),
      'invoice_datestart'    => new sfValidatorDate(),
      'invoice_dateend'      => new sfValidatorDate(),
      'invoice_servicestart' => new sfValidatorDate(),
      'invoice_serviceend'   => new sfValidatorDate(),
      'invoice_benchmark'    => new sfValidatorNumber(),
      'invoice_newprice'     => new sfValidatorNumber(),
      'invoice_hauler_cost'  => new sfValidatorNumber(),
      'invoice_comments'     => new sfValidatorString(),
      'invoice_deleted'      => new sfValidatorChoice(array('choices' => array(0 => 'no', 1 => 'yes'), 'required' => false)),
      'invoice_paid'         => new sfValidatorChoice(array('choices' => array(0 => 'no', 1 => 'yes'), 'required' => false)),
      'invoice_hauler_paid'  => new sfValidatorChoice(array('choices' => array(0 => 'no', 1 => 'yes'), 'required' => false)),
      'invoice_sent'         => new sfValidatorChoice(array('choices' => array(0 => 'yes', 1 => 'no'), 'required' => false)),
      'invoice_send_date'    => new sfValidatorDateTime(),
      'invoice_last_send'    => new sfValidatorDateTime(),
      'invoice_paid_date'    => new sfValidatorDateTime(),
      'account_id'           => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Account'))),
    ));

    $this->widgetSchema->setNameFormat('invoice[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Invoice';
  }

}
